package org.finesys.chat.core.base.document.tokenizer;


import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import org.finesys.ai.core.chat.Message;
import org.finesys.chat.core.base.agent.ToolExecutionRequest;
import org.finesys.chat.core.base.agent.ToolSpecification;
import org.finesys.chat.core.base.agent.ToolSpecifications;

public interface Tokenizer {
    int estimateTokenCountInText(String text);

    int estimateTokenCountInMessage(Message message);

    int estimateTokenCountInMessages(Iterable<Message> messages);

    default int estimateTokenCountInTools(Object objectWithTools) {
        return this.estimateTokenCountInTools((Iterable<Object>) Collections.singletonList(objectWithTools));
    }

    default int estimateTokenCountInTools(Iterable<Object> objectsWithTools) {
        List<ToolSpecification> toolSpecifications = new ArrayList<>();
        objectsWithTools.forEach((objectWithTools) -> {
            toolSpecifications.addAll(ToolSpecifications.toolSpecificationsFrom(objectWithTools));
        });
        return this.estimateTokenCountInToolSpecifications(toolSpecifications);
    }

    int estimateTokenCountInToolSpecifications(Iterable<ToolSpecification> var1);

    default int estimateTokenCountInForcefulToolSpecification(ToolSpecification toolSpecification) {
        return this.estimateTokenCountInToolSpecifications(Collections.singletonList(toolSpecification));
    }

    int estimateTokenCountInToolExecutionRequests(Iterable<ToolExecutionRequest> var1);

    default int estimateTokenCountInForcefulToolExecutionRequest(ToolExecutionRequest toolExecutionRequest) {
        return this.estimateTokenCountInToolExecutionRequests(Collections.singletonList(toolExecutionRequest));
    }
}
